const db = require("../../database");
const writeLogs = require('./writeLogs');

module.exports = (req, res) => {
    const {messages} = req.body;
    const username = req.auth.username;
    let sql = 'update users set messages = ? where username = ?';
    db.query(sql, [messages, username], (err, data) => {
        if (err) {
            writeLogs('err', { err });
            return res.cc(err)
        }
        if (!data.affectedRows) return res.cc('数据更新失败')
        res.cc('消息数据更新成功', 0);
    })
}